package test.study.java.jol.samples;

import lombok.extern.slf4j.Slf4j;
import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.vm.VM;

@Slf4j
public class JOLSample_08_Class {

    /*
     * Another example of special treatment for some fields.
     *
     * If you run this example, you can see the large gap in instance field block.
     * There are no Java fields that could claim that block, hence there are no
     * "hidden" fields, like in the example before. This time, VM "injects" some
     * of the fields into the Class, to store some of the meta-information there.
     *
     * See:
     *  https://github.com/openjdk/jdk/blob/fd45694c58452635db572cb55e5a1b2cb7bc34b2/src/hotspot/share/classfile/javaClasses.hpp#L219-L226
     */

    public static void main(String[] args) {
        log.info(VM.current().details());
        log.info(ClassLayout.parseClass(Class.class).toPrintable());
    }
}
